package com.affablebeans.cart;

import com.affablebeans.model.entity.Product;

/**
 * 
 * @author Bora SAYINER
 * @since Jan 31, 2015 6:35:29 PM
 * @version 1.0.0
 */
public class ShoppingItem {

	private Product product;
	private int quantity;

	public ShoppingItem(Product product) {
		this.product = product;
		this.quantity = 1;
	}

	public Product getProduct() {
		return product;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public void incrementQuantity() {
		this.quantity++;
	}

	public void decrementQuantity() {
		this.quantity--;
	}

	public double getTotal() {
		return quantity * product.getPrice();
	}

	@Override
	public String toString() {
		return "ShoppingItem [product=" + product + ", quantity=" + quantity + "]";
	}

}
